/**
 * 
 */
package xxm.utility.action;

import java.util.Vector;

import xxm.utility.action.event.BasicActionEvent;
import xxm.utility.action.listener.BasicActionListener;


/**
 * @author xxm
 *
 */
public class BasicActionComponent {
	
	private int value;
	private Vector<BasicActionListener> listeners = new Vector<BasicActionListener>();

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
		fireChanged();
	}
	
	public void addListener(BasicActionListener l) {
		listeners.add(l);
	}
	
	private void fireChanged(){
		BasicActionEvent e = new BasicActionEvent();
	    e.setValue(value);
	    for(int i=0;i<listeners.size();i++){
	      BasicActionListener l=(BasicActionListener)listeners.elementAt(i);
	      l.actionPerformed(e);
	    }
	  }
	
	
}
/*
	BasicActionComponent ms=new BasicActionComponent();
	BasicActionListener ml=new BasicMyActionListener();
	ms.addListener(ml);
	ms.setValue(10);
*/
